---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: access-to-agent-agent-prometheus-metrics
  namespace: d8-{{ .Chart.Name }}
  {{- include "helm_lib_module_labels" (list . (dict "app" "agent")) | nindent 2 }}
rules:
- apiGroups: ["apps"]
  resources: ["daemonsets/prometheus-metrics"]
  resourceNames: ["agent"]
  verbs: ["get"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: access-to-agent-agent-prometheus-metrics
  namespace: d8-{{ .Chart.Name }}
  {{- include "helm_lib_module_labels" (list . (dict "app" "agent")) | nindent 2 }}
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: access-to-agent-agent-prometheus-metrics
subjects:
- kind: User
  name: d8-monitoring:scraper
- kind: ServiceAccount
  name: prometheus
  namespace: d8-monitoring
